Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #5122

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Solution #5122

wants to merge 2 commits into from

Conversation

KateShepel
Copy link

No description provided.

Copy link

@alexander-ignatow alexander-ignatow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mind some issues - but it is all good overall 👍

Comment on lines +7 to +12
const PRICE_OF_RENT = 40;
let totalCost = days * PRICE_OF_RENT;
const SHORT_TERM = 3;
const SMALL_DISCOUNT = 20;
const LONG_TERM = 7;
const BIG_DISCOUNT = 50;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please declare consts outside functions if possible - with your solution you re-declare these variables on each function call

Comment on lines +18 to +26
if (days < LONG_TERM) {
totalCost = totalCost - SMALL_DISCOUNT;

return totalCost;
}

totalCost = totalCost - BIG_DISCOUNT;

return totalCost;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to reassign totalCost
Just return what you need

Suggested change
if (days < LONG_TERM) {
totalCost = totalCost - SMALL_DISCOUNT;
return totalCost;
}
totalCost = totalCost - BIG_DISCOUNT;
return totalCost;
if (days < LONG_TERM) {
return totalCost - SMALL_DISCOUNT;
}
return totalCost - BIG_DISCOUNT;

If you do this - you can change
let totalCost = days * PRICE_OF_RENT; to
const totalCost = days * PRICE_OF_RENT;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants